'use strict';

module.exports = {
    up: async (queryInterface, Sequelize) => {
        const { STRING, INTEGER, DATE, BOOLEAN, NOW } = Sequelize;

        await queryInterface.createTable(
            'tbl_system_message',
            {
                id: {
                    type: INTEGER,
                    primaryKey: true,
                    autoIncrement: true
                },
                type: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                state: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 1
                },
                title: {
                    type: STRING(32),
                    allowNull: false
                },
                content: {
                    type: STRING,
                    allowNull: true
                },
                user_id: {
                    type: INTEGER,
                    allowNull: true
                },
                priority: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                read_state: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 1
                },
                created_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                },
                updated_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                }
            },
            {
                charset: 'utf8'
            });

        await queryInterface.createTable(
            'tbl_user_verify',
            {
                id: {
                    type: INTEGER,
                    primaryKey: true,
                    autoIncrement: true
                },
                user_id: {
                    type: INTEGER,
                    allowNull: false
                },
                verify_type: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                verify_state: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                content: {
                    type: STRING,
                    allowNull: true
                },
                created_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                },
                updated_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                }
            },
            {
                charset: 'utf8'
            });

        await queryInterface.createTable(
            'tbl_member_complaint',
            {
                id: {
                    type: INTEGER,
                    primaryKey: true,
                    autoIncrement: true
                },
                type: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 1
                },
                state: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 1
                },
                user_id: {
                    type: INTEGER,
                    allowNull: false
                },
                target_user_id: {
                    type: INTEGER,
                    allowNull: false
                },
                content: {
                    type: STRING,
                    allowNull: false
                },
                image: {
                    type: STRING(128),
                    allowNull: true
                },
                replay: {
                    type: STRING,
                    allowNull: true
                },
                created_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                },
                updated_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                }
            },
            {
                charset: 'utf8'
            });

        await queryInterface.createTable(
            'tbl_user_label',
            {
                id: {
                    type: INTEGER,
                    primaryKey: true,
                    autoIncrement: true
                },
                user_id: {
                    type: INTEGER,
                    allowNull: false
                },
                label_type: {
                    type: INTEGER,
                    allowNull: false,
                    defaultValue: 0
                },
                label_value: {
                    type: INTEGER,
                    allowNull: false
                },
                created_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                },
                updated_at: {
                    type: DATE,
                    allowNull: false,
                    defaultValue: NOW
                }
            },
            {
                charset: 'utf8'
            });
    },

    down: async (queryInterface, Sequelize) => {
        // await queryInterface.dropTable('tbl_system_message');
        // await queryInterface.dropTable('tbl_user_verify');
        // await queryInterface.dropTable('tbl_member_complaint');
        // await queryInterface.dropTable('tbl_user_label');
    }
};
